#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#include "music_window.h"
#include <QWidget>
#include <QPainter>
#include <beep_window.h>
#include <QFile>
#include "time_weather_data.h"
#include "map_window.h"
#include <QTimer>
#include <QMainWindow>
#include <QPushButton>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkAccessManager>
#include <QLabel>
#include <QTextCodec>
#include <QByteArray>
#include <QtNetwork/QNetworkRequest>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
#include <QMessageBox>
#include <QHBoxLayout>
#include <QJsonArray>
#include "pichoose_window.h"
namespace Ui {
class Main_Window;
}

class Main_Window : public QWidget
{
    Q_OBJECT


private:
    QNetworkAccessManager *manage = new QNetworkAccessManager();
    QByteArray bytes;
    QString all;
public:
    explicit Main_Window(QWidget *parent = nullptr);
    ~Main_Window();
    //获取天气
    void weather_init(QString id);
    void weather_dispose(QString str);
    void paintEvent(QPaintEvent *event);
    bool eventFilter(QObject *obj, QEvent *event);
    void show_mainwindow();
    int picture_flag=0;
    int old_picture_flag = 0;
    QString picture_name = "\0";
    QString city_id="101160101";
    //定时器对象
    QTimer *timer_obj = new QTimer(this);

    //主界面数据变量
    //第一个框
    int hour = 19;
    int minute = 25;
    int second = 0;
    int time_flag = 1; // 上午是0，下午是1

    int year = 2021;
    int month = 10;
    int day = 24;

    //第二个框
    QString *local = new QString("兰州");
    int tempature = 5;
    int weather = 0;//0：晴天，1：雨天，2：多云，3：雪天
    //第三个框
    QPainter my_painter;
    int wifi_state = 1;
    int lanya_state = 0;

    //界面切换实现
    Beep_window *Beep_page = NULL;
    Music_window *Music_page = NULL;
    Pichoose_window *Pichoose_page = NULL;
    Map_window *Map_page = NULL;
    //文件路径
    QFile *GPIO_File = new QFile("/sys/class/gpio/export");
    QFile *Beep_directon_File = new QFile("/sys/class/gpio/gpio19/direction");
    QFile *Beep_value_File = new QFile("/sys/class/gpio/gpio19/value");
private slots:
    //按键触发
    void on_Beep_but_clicked();
    void on_Crema_but_clicked();
    void replyfinished(QNetworkReply *reply);
    void on_Music_but_clicked();
    void on_Picture_but_clicked();

signals:
    void back();

private:
    Ui::Main_Window *ui;
};

#endif // MAIN_WINDOW_H
